
package model;

public class Entity extends GameObject implements Ticked{

	private Tile location;
	private Inventory inventory;
	private Item[] equippedItems;
	private String name;

	private int lives;
	private int strength;
	private int agility;
	private int intellect;
	private int hardiness;
	private int experience;
	private int speed;

	private boolean canClimb;
	private boolean canSwim;

	private Direction movingDirection;

	private long movingTicks;

	/*public boolean addObserver(Observer o)
	{
		return(false);
	}*/
	public boolean tick()
	{
		if(movingDirection != null)
		{
			if(movingTicks % 6 == 0)
			{
				moveOne(movingDirection);
			}
			movingTicks++;
		}
		return(true);
	}

	public boolean canClimb()
	{
		return(canClimb);
	}
	public boolean canSwim()
	{
		return(canSwim);
	}
	public boolean move(Tile nextTile)
	{
		if((nextTile.getTerrain().canPass(this))&&(!(nextTile.getItem().isImpassable()))&&(nextTile.getEntity()==null))
		{
			location.setEntity(null);
			nextTile.setEntity(this);
			location = nextTile;
			if(location.getItem() != null)
			{
				location.getItem().touch(this);
			}
			return(true);
		}
		else
		{
			return(false);
		}
	}
	public boolean move(Direction movementDirection)
	{
		movingDirection = movementDirection;
		return(true);
	}
	public boolean moveOne(Direction movementDirection)
	{
		//get correct tile and call move(Tile)
		Tile nextTile = location.getNeighbor(movementDirection);
		if(nextTile != null)
		{
			return(move(nextTile));
		}
		else
		{
			return(false);
		}
	}
	public boolean stop()
	{
		movingDirection = null;
		return(true);
	}
	public int getLevel()
	{//skeleton
		return(experience/1000);
	}
	public int getLife()
	{//skeleton
		return(hardiness);
	}
	public int getMana()
	{//skeleton
		return(intellect);
	}
	public int getOffense()
	{//skeleton
		return(strength);
	}
	public int getDefense()
	{//skeleton
		return(agility);
	}
	public int getArmor()
	{//skeleton
		return(hardiness+agility);
	}
	
	/** next 4 methods are used for areaEffect class **/
	
	//increases to next level
	public void increaseLevel()
	{
		experience = (experience/1000) + 1000;
	}
	//decreases total life
	public void takeDamage()
	{
		hardiness--;
	}
	
	//heals life
	public void healDamage()
	{
		hardiness++;
	}
	
	//kills the entity
	public void death()
	{
		hardiness = 0;
	}
	/** end of methods for area effect class **/
	
	
	public Tile getLocation() {
		return location;
	}
	public void setLocation(Tile location) {
		this.location = location;
	}
	public Inventory getInventory() {
		return inventory;
	}
	public void setInventory(Inventory inventory) {
		this.inventory = inventory;
	}
	public Item[] getEquippedItems() {
		return equippedItems;
	}
	public void setEquippedItems(Item[] equippedItems) {
		this.equippedItems = equippedItems;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getLives() {
		return lives;
	}
	public void setLives(int lives) {
		this.lives = lives;
	}
	public int getStrength() {
		return strength;
	}
	public void setStrength(int strength) {
		this.strength = strength;
	}
	public int getAgility() {
		return agility;
	}
	public void setAgility(int agility) {
		this.agility = agility;
	}
	public int getIntellect() {
		return intellect;
	}
	public void setIntellect(int intellect) {
		this.intellect = intellect;
	}
	public int getHardiness() {
		return hardiness;
	}
	public void setHardiness(int hardiness) {
		this.hardiness = hardiness;
	}
	public int getExperience() {
		return experience;
	}
	public void setExperience(int experience) {
		this.experience = experience;
	}
	public int getSpeed() {
		return speed;
	}
	public void setSpeed(int speed) {
		this.speed = speed;
	}
}
